// pages/post7/post7.js
const app = getApp(), core = require('../../utils/core');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    job: {},
  },
  nav:function(e) {
    var nav=this.data.nav;
    nav[e.currentTarget.dataset.index].check = !nav[e.currentTarget.dataset.index].check
    this.setData({
      nav: nav
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getOpenerEventChannel().on('jobTransfer', job => {
      this.setData({job: job});
    });
  },
  bindToggle: function (event) {
    let name = event.currentTarget.dataset.name;
    this.setData({
      ['job.'+name]: !!this.data.job[name] ? 0:1
    });
  },
  bindRedPacketInput: function (event) {
    this.setData({
      'job.red_packet': parseInt(event.detail.value),
    })
  },
  bindRedPacketInstructionInput: function (event) {
    this.setData({
      instruction: event.detail.value
    })
  },
  bindNextStep: function () {
    this.setData({['job.red_packet_instruction']:this.data.instruction});
    wx.navigateTo({url: '/pages/post4/post4', success: res => {
      res.eventChannel.emit("jobTransfer", this.data.job);
    }});
  }


});
